<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/tentime">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
    <style type="text/css">
        .layui-form-radio {margin: 0px 5px 0 0 !important;}
        .layui-input-block {margin-left: 0px!important;}
        .layui-upload-img{width:100px;height: 100px;}
    </style>
</head>
<body>
<div class="layui-form tentime-compile">
    <form id="inputForm" th:object="${entity}" class="layui-form">
        <input id="id" type="hidden" name="id" th:if="${entity}" th:value="${entity?.id}"/>
        <div class="layui-form-item">
	        <div class="layui-inline">
	            <label class="layui-form-label required">租户标识</label>
	            <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="tenantId" placeholder="请输入租户标识" th:value="${entity?.tenantId}">
	            </div>
	        </div>
            <div class="layui-inline">
                <label class="layui-form-label required">租户名称</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="tenantName" placeholder="请输入客户名称" th:value="${entity?.tenantName}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">初始化</label>
                <div class="layui-input-inline">
                    <input type="radio" name="init" value="1" title="是" th:checked="${entity?.init} eq 1" disabled="">
                    <input type="radio" name="init" value="0" title="否" th:checked="${entity?.init} eq 0" disabled="">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label required">租户简称</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="shortName" placeholder="请输入租户标识" th:value="${entity?.shortName}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">URL</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="url" placeholder="请输入数据库URL" th:value="${entity?.url}" style="width: 603px!important;">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">用户</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="username"  placeholder="请输入用户名称" th:value="${entity?.username}">
                </div>
            </div>
        	<div class="layui-inline">
	        	<label class="layui-form-label required">密码</label>
	            <div class="layui-input-inline">
	                <input class="layui-input" lay-verify="required" type="text" name="password"  placeholder="请输入用户密码" th:value="${entity?.password}">
	            </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">连接超时</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required|number" type="text" name="connectionTimeout"  placeholder="请输入" th:value="${entity?.connectionTimeout}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label required">空闲时长</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required|number" type="text" name="idleTimeout"  placeholder="请输入" th:value="${entity?.idleTimeout}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">最小连接数</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required|number" type="text" name="minimumIdle"  placeholder="请输入" th:value="${entity?.minimumIdle}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label required">最大连接数</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required|number" type="text" name="maximumPoolSize"  placeholder="请输入" th:value="${entity?.maximumPoolSize}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-inline" style="width: 603px;!important;">
                    <textarea id="remarks" name="remarks" th:utext="${entity?.remarks}" style="display: none;"></textarea>
                    <!--
                    <textarea id="remarks" name="remarks" th:utext="${entity?.remarks}" autoHeight="true" style="width: 100%"></textarea>
                    -->
                </div>
            </div>
            <!--
            <div class="layui-inline">
                <label class="layui-form-label">LOGO图片</label>
                <div class="layui-input-inline">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="fileUpload">上传图片</button>
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" id="logo" th:src="${#request.getContextPath()} + ${logoPath}">
                        </div>
                    </div>
                </div>
            </div>
            -->
        </div>
        <div class="layui-form-item tentime-finally">
            <button class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="submit_button" shiro:hasAnyPermissions="masterTenat:add,masterTenat:edit"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn layui-btn-sm layui-btn-primary" onclick="closeWin();" type="button"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
<script th:replace="/common/template :: common"></script>
<script type="text/javascript" th:inline="javascript">
    layui.use(['form','layer','layedit', 'jquery'], function () {
        window.form = layui.form;
        layer = layui.layer, $ = layui.jquery, layedit = layui.layedit;
        /*
        var refId = $('#id').val();
        $("#fileUpload").click(function() {//附件上传
            if (refId === '') refId = randomStr(18);//默认生成18位的随机id赋值给FileUpload
            var url_upload = ctx + '/file/fileUpload?refId=' + refId + '&type=logo&fileType=images&filenum=1&path=logo';// String refId, String type, String fileType, String path, int filenum
            openWin("附件上传", url_upload, 750, 500, refId);
        });
        */
        //富文本设置
        var index = layedit.build('remarks', {
            tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right','|', 'table', 'fullScreen', 'preview'],
            height: 80
        });
        //表单提交
        form.on("submit(submit_button)", function (data) {
            var content = layedit.getContent(index);
            $('#remarks').text(content);
	        $("#inputForm").ajaxSubmit({
				type : "post"
	            ,url : ctx + '/masterTenant/saveEntity'
                /*,data: {'refId': refId}*/
	            ,success : function(data) {
	            	var code = data.code;
	            	if (code == 200) {
	            		parent.layer.msg('数据保存成功!', {icon: 1});
	            		closeWin();
	            		window.parent.reloadTable();
	            	} else {
	            		parent.layer.msg('数据验证失败!', {icon: 2});
	            	}
	            }
			});
       		return false;
       	});
        /*
        window.reloadParent = function(pid) {//关闭附件上传窗口时执行的方法,刷新数据列表
            console.log('执行父页面方法,刷新附件列表：' + pid);
        };
        */
    });

</script>
</body>
</html>